<?php if (!defined('THINK_PATH')) exit();?><div>
	<div class="btn-toolbar">
		<div class="btn-group">
			<button class="btn">通讯录分组</button>
			<button class="btn dropdown-toggle" data-toggle="dropdown">
			<span class="caret"></span>
			</button>
			<ul class="dropdown-menu">
				<?php if(is_array($group)): $i = 0; $__LIST__ = $group;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><li><a href="#Contacts#myContact#<?php echo ($vo["group_name"]); ?>" id="<?php echo ($vo["group_id"]); ?>" onclick="per_group('<?php echo U('Contacts/myContact');?>',id);"><?php echo ($vo["group_name"]); ?></a></li><?php endforeach; endif; else: echo "" ;endif; ?>
				<li><a href="#Contacts#myContact#未分类" id="0" onclick="per_group('<?php echo U('Contacts/myContact');?>',id);">未分类</a></li>
			</ul>
		</div>
		<div class="btn-group">
			<button class="btn" onclick="addContactGrounp('<?php echo U('Contacts/addGroup');?>');">添加分组</button>
			<button class="btn" onclick="addContact('<?php echo U('Contacts/addContact');?>');">添加联系人</button>
		</div>
	<div class="contact-search btn-group" style="float:right;">
		<form action="" method="post" onsubmit="return false;">
			<input type="text" placeholder="姓名" style="width:100px;margin-right:5px;" name="name"/>
			<input type="text" placeholder="手机号" style="margin-right:5px" name="mobile"/>
			<button type="submit" class="btn" onclick="searchContact('__APP__/Contacts/myContact')">搜索</button>
		</form>
	</div>
	</div>
	<div class="contact-list">
		<table class="table table-bordered table-hover"  style="text-align:center">
			<thead><tr style="background:#F5F5F5"><td><input type="checkbox" id="contact-delete-all" onclick="selectAllContact();"/></td><td>ID</td><td>姓名</td><td>手机号</td><td>分组</td><td>公司名称</td><td>公司电话</td><td>操作</td></tr></thead>
			<tbody>
				<?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr id="contacter_<?php echo ($vo["contacter_id"]); ?>"><td><input type="checkbox" class="contact-delete"/></td>
					    <td><?php echo ($vo["contacter_id"]); ?></td>
						<td><?php echo ($vo["name"]); ?></td>
					    <td><?php echo ($vo["mobile"]); ?></td>
						<td><?php echo ($vo["group_name"]); ?></td>
						<td><?php echo ($vo["company"]); ?></td>
						<td><?php echo ($vo["comtel"]); ?> </td>
						<td width=100><span class="label label-important" style="cursor:pointer" id="<?php echo ($vo["contacter_id"]); ?>" onclick="edit(id);">编辑</span><span class="label label-important" style="cursor:pointer;margin-left:5px" onclick="delContacter(<?php echo ($vo["contacter_id"]); ?>)">删除</span></td></tr><?php endforeach; endif; else: echo "" ;endif; ?>
			</tbody>
		</table>
	</div>
	<div class="pagination" style="float:right">
		<select name="pageNum" style="margin-top:-20px;width:60px">
			<option>10</option>
			<option>20</option>
			<option>30</option>
		</select>
		<?php echo ($page); ?>
	</div>
</div>
<style>
	.contact-list input{
		 background-color:#FFFFFF;border: 1px solid #FFFFFF; box-shadow: 0 0 0 rgba(0, 0, 0, 0.075) inset;text-align:center;
	}
</style>
<script>
	//显示分组联系人
	function per_group(url,group_id){
		$("#maincontent").load(url,{group_id:group_id});
	}
	//搜索
	function searchContact(url){
		$('#maincontent').load(url,{name:getInputValueByName('name'),mobile:getInputValueByName('mobile')});
	}
	//编辑
	function edit(id){
		$.dialog("完善联系人","__APP__/Contacts/editContact/contacter_id/"+id);
	}
	function delContacter($contacter_id){
		$.getJSON("__APP__/Contacts/delContacter",{contacter_id:$contacter_id},function(json){
			if(json.status == 1){
				$("#contacter_"+$contacter_id).remove();
			}else{
				$.warn("系统提示",json.info);
			}
		});
	}

</script>